<?php

$line = array('CUSTOMER ID', 'ACCOUNT_NUMBER', 'SALUTATION', 'INST_LAST_NAME', 'INST_FIRST_NAME','BILL_STREET','BILL_HOUSE_NO','BILL_ZIP','BILL_CITY');
$csv->addRow($line);

foreach($result AS $r)
  {
    $line = array($r['c']['id'], $r['c']['account_number'], $r['c']['salutation'], $r['c']['inst_last_name'], $r['c']['inst_first_name'], $r['c']['bill_street'], $r['c']['bill_house_no'], $r['c']['bill_zip'], $r['c']['bill_city']);
    $csv->addRow($line);
  }

$datum = date("d.m.Y");
$end = ".csv";
$title = "Export_Intrum_Runid-".$runid."_".$datum.".csv";
echo $csv->render($title);


?>